<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfMybankOrderOrderWithholdMapping extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mybank_order_record_withhold_mappings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('orderRecordId')->default(0)->comment("账单ID");
            $table->unsignedBigInteger('orderWithholdRecordId')->default(0)->comment("协议代扣记录 ID");
            $table->unsignedInteger('amount')->default(0)->comment("代扣金额");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->index(['orderRecordId'], 'idx_orderRecordId');
            $table->index(['orderWithholdRecordId'], 'idx_orderWithholdRecordId');
            $table->index(['createdAt'], 'idx_createdAt');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '网商代扣关联订单';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mybank_order_record_withhold_mappings');
    }
}
